import Snippet from '~/components/snippet'
import Caption from '~/components/text/caption'
import { InlineCode } from '~/components/text/code'
import Note from '~/components/text/note'
import Link from '~/components/text/link'

export const meta = {
  editUrl: 'pages/docs/now-cli/now-cli-mdx/commands/now.mdx',
  lastEdited: '2019-10-15T22:03:42.000Z'
}

## Now

The `now` command is used to deploy projects and can be used from either the root of the project directory or by providing a path to it.

### Basic Usage

<Snippet dark text="now" />
<Caption>Using the <InlineCode>now</InlineCode> command from the root of a project directory.</Caption>

### Extended Usage

<Snippet dark text="now [path-to-project]" />
<Caption>Using the <InlineCode>now</InlineCode> command and supplying a path to the root directory of the project.</Caption>

### Project Linking

When running `now` in a directory for the first time, [Now CLI](/download) needs to know which [scope](/docs/now-cli#options/global-options/scope) and [Project](/docs/v2/platform/projects) you
want to deploy your directory to. You can choose to either link an existing project or to create a new one.

<Note>
  Project linking requires at least version 17 of{' '}
  <Link href="/download">Now CLI</Link>. If you have an earlier version, please{' '}
  <Link href="/guides/updating-now-cli">update</Link> to the latest version.
</Note>

<br />

<Snippet clipboard={false} dark text={`now
? Set up and deploy “~/web/my-lovely-project”? [Y/n] y
? Which scope do you want to deploy to? My Awesome Team
? Link to existing project? [y/N] y
? What’s the name of your existing project? my-lovely-project
🔗 Linked to awesome-team/my-lovely-project (created .now and added it to .gitignore)`} />
<Caption>Linking an existing project when running <InlineCode>now</InlineCode> in a new directory.</Caption>

Once set up, a new `.now` directory will be added to your directory. The `.now` directory contains
both the organization and project `id` of your project. If you want unlink your directory, you can remove the `.now` directory.

You can use the[`--confirm` option](#commands/now/unique-options/confirm) to skip these questions.

### Framework Detection

When you create a new project, Now CLI will automatically detect the framework you are using and offer
default project settings accordingly.

<Snippet clipboard={false} dark text={`now
? Set up and deploy “~/web/my-new-project”? [Y/n] y
? Which scope do you want to deploy to? My Awesome Team
? Link to existing project? [y/N] n
? What’s your project’s name? my-new-project
? In which directory is your code located? my-new-project/
Auto-detected project settings (Next.js):
- Build Command: \`next build\` or \`build\` from \`package.json\`
- Output Directory: Next.js default
- Development Command: next dev --port $PORT
? Want to override the settings? [y/N]`} />
<Caption>Creating a new project with the <InlineCode>now</InlineCode> command.</Caption>

When creating a new project, you will be provided with default **Build Command**, **Output Directory**, and **Development Command** options.

You can continue with the default project settings or overwrite them. You can also edit your project settings later in your project dashboard.

### Global Options

The following [global options](#options) can be passed when using the `now` command:

- `--debug`
- `--force`
- `--help`

For more information on global options and their usage, refer to the [options section](#options).

### Unique Options

These are options that only apply to the `now` command, therefore, more information is provided.

#### Build Env

The `--build-env` option, shorthand `-b`, can be used to provide environment variables to the [build step](/docs/v2/build-step).

##### Usage Example

<Snippet dark text="now --build-env [key1=value1 key2=value2 key3=value3]" />
<Caption>Using the <InlineCode>now</InlineCode> command with the <InlineCode>--build-env</InlineCode> option.</Caption>

#### Confirm

The `--confirm` option can be used to skip questions you are asked when setting up a new project.
The questions will be answered with the provided defaults, inferred from `now.json` and the folder name.

##### Usage Example

<Snippet dark text="now --confirm" />
<Caption>Using the <InlineCode>now</InlineCode> command with the <InlineCode>--confirm</InlineCode> option.</Caption>

#### Env

The `--env` option, shorthand `-e`, can be used to provide environment variables at [run time](/docs/v2/serverless-functions/env-and-secrets).

##### Usage Example

<Snippet dark text="now --env [key1=value1 key2=value2 key3=value3]" />
<Caption>Using the <InlineCode>now</InlineCode> command with the <InlineCode>--env</InlineCode> option.</Caption>

#### Name

<Note type="alert">
  The <InlineCode>--name</InlineCode> option has been deprecated in favor of{' '}
  <Link href="#commands/now/project-linking">Project Linking</Link>, which
  allows you to link a ZEIT Now Project to your local codebase when you run
  <InlineCode>now</InlineCode>.
</Note>

The `--name` option, shorthand `-n`, can be used to provide a project name for a deployment.

##### Usage Example

<Snippet dark text="now --name foo" />
<Caption>Using the <InlineCode>now</InlineCode> command with the <InlineCode>--name</InlineCode> option.</Caption>

#### No Clipboard

The `--no-clipboard` option, shorthand `-C`, can be used to prevent Now CLI from copying the deployment URL to the clipboard.

##### Usage Example

<Snippet dark text="now --no-clipboard" />
<Caption>Using the <InlineCode>now</InlineCode> command with the <InlineCode>--no-clipboard</InlineCode> option.</Caption>

#### Prod

The `--prod` option can be used to create a deployment for a production domain specified in the project dashboard.

##### Usage Example

<Snippet dark text="now --prod" />
<Caption>Using the <InlineCode>now</InlineCode> command with the <InlineCode>--prod</InlineCode> option.</Caption>

#### Public

The `--public` option can be used to ensures the source code is publicly available at the `/_src` path.

##### Usage Example

<Snippet dark text="now --public" />
<Caption>Using the <InlineCode>now</InlineCode> command with the <InlineCode>--public</InlineCode> option.</Caption>

#### Regions

The `--regions` option can be used to specify which regions the deployments [Serverless Functions](/docs/v2/serverless-functions/introduction) should run in.

##### Usage Example

<Snippet dark text="now --regions sfo1" />
<Caption>Using the <InlineCode>now</InlineCode> command with the <InlineCode>--regions</InlineCode> option.</Caption>

#### Version

The `--version` option can be used to verify the version of [Now CLI](/download) currently being used.

##### Usage Example

<Snippet dark text="now --version" />
<Caption>Using the <InlineCode>now</InlineCode> command with the <InlineCode>--version</InlineCode> option.</Caption>
